﻿@model SpaceNeedle.City6473.WebSite.Models.RequestItemsModel
@using SpaceNeedle.City6473.Web.Data.Models

@{
    Layout = "~/Views/Shared/_LayoutSolicitacao.cshtml";

    var staticContent = ViewBag.StaticContent as WebSiteContent;
    ViewBag.Title = "Solicitação: " + Model.NewRequestItem.Request.Description;

    ViewBag.MetaMap = "http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/Model.NewRequestItem.Geoposition?mapSize=200,200&amp;pushpin=" + Model.NewRequestItem.Geoposition + ";68;;&amp;mapLayer=mapLayer&amp;format=png&amp;key=" + System.Configuration.ConfigurationManager.AppSettings["bindMapsKey"]; ;
    ViewBag.MetaDescription = Model.NewRequestItem.Description;
    ViewBag.MetaUrl = Model.NewRequestItem.Permalink;

    Model.NewRequestItem.Geoposition = Model.NewRequestItem.Geoposition.Replace(" ", "");
}

<h2>@Model.NewRequestItem.Request.Title</h2>
    <span>@Model.NewRequestItem.Request.Description</span><br /><br />
    <iframe allowtransparency="true" frameborder="0" scrolling="no" src="https://platform.twitter.com/widgets/tweet_button.html?url=@Request.Url.ToString()" style="width:60px; height:22px;"></iframe>
    <iframe src="//www.facebook.com/plugins/like.php?href=@Request.Url.ToString()&amp;width&amp;layout=button&amp;action=like&amp;show_faces=false&amp;share=true&amp;height=35" scrolling="no" frameborder="0" style="border:none; overflow:hidden; height:22px;" allowtransparency="true"></iframe>        
    
<br /><br />
<div class="control-group">
    <strong>@staticContent.RequestItems.Address</strong>
    <label>@Model.NewRequestItem.Address</label>
</div>

<div class="control-group">
    <strong>@staticContent.RequestItems.Geolocation</strong>
    <div class="noots-map" style="margin-top:10px;width:612px;height:200px;background-color:#c0c0c0">
        <img id="map" style="display:none;">
    </div>
</div>

<div class="control-group">
    <strong>@staticContent.RequestItems.CreatedBy</strong>
    <label>@Model.NewRequestItem.User.Name</label>
</div>

<div class="control-group">
    <strong>@staticContent.RequestItems.CreationDate</strong>
    <label>@Model.NewRequestItem.CreationDate</label>
</div>

<div class="control-group">
    <strong>@staticContent.RequestItems.Supporters<span style="font-family:'Segoe UI Symbol'">&nbsp;@Html.Raw(staticContent.RequestItems.SupportersSymbol)</span></strong>
    <label id="supporters_@Model.NewRequestItem.Id">0</label>
</div>

<div class="control-group">
    <strong>@staticContent.RequestItems.Status</strong>
    <label>@(new SpaceNeedle.City6473.Web.Data.Repositories.StatusRepository().GetById(Model.NewRequestItem.Status).Name)</label><br />
    <span>@Model.NewRequestItem.StatusInfo</span>
</div>

<div class="control-group">
    <strong>@staticContent.RequestItems.Photo</strong>
    <br />
    <img src="@Model.NewRequestItem.Photo.Replace(".jpg", "_612.jpg")" style="width: 612px;">
</div>

<div class="control-group">
    <strong>@staticContent.RequestItems.Description</strong>
    <p >@Model.NewRequestItem.Description</p>
</div>

<script>
    var supporters = new Object();

    function SetSupporters(id) {
        $.getJSON("/api/requestitems/" + id + "/supporters/count",
            function (data) {
                supporters[id] = data;
                $("#supporters_" + id).text(data);
                $("#map").attr("src", "http://dev.virtualearth.net/REST/v1/Imagery/Map/Road/@(Model.NewRequestItem.Geoposition)/12?mapSize=612,200&pushpin=@(Model.NewRequestItem.Geoposition);68;" + data + "&mapLayer=mapLayer&format=png&key=AsH6nhDGxQ_T46DUCqpLHT5bZKSMARwNlWuul3Lpk6krI735pl7qRzZcPA8_0y35")
                $("#map").show();
            });

    }

    function GetSupporters(id) {
        if (supporters[id] == null) {
            return 0;
        }

        return supporters[id];
    }

    $(document).ready(function () {
        SetSupporters('@Model.NewRequestItem.Id');

    });

</script>


